//
//  MCTabBarContro.swift
//  MCBodyBuildingPro
//
//  Created by 然陈 on 2023/6/18.
//

import UIKit

class MCTabBarContro: UITabBarController {
    
    override func viewDidLoad() {
            super.viewDidLoad()
            // 添加首页
            addChildren(MCPlanVc(), title: "计划", normalIcon: "plan_unselect_tabbar_image", selectIcon: "plan_select_tabbar_image",index:0)
            addChildren(MCActionVc(), title: "动作", normalIcon: "action_tabbar_unselect_image", selectIcon: "action_tabbar_select_image",index:1)
            addChildren(MCDietVc(), title: "饮食", normalIcon: "yinshi_unselect_tabbar_image", selectIcon: "yinshi_select_tabbar_image",index:2)
            // 我的
            addChildren(MCMineVc(), title: "我的", normalIcon: "mine_tabbar_unselect_image", selectIcon: "mine_tabbar_select_image",index: 3)
            
        }
    
    /// 添加自控制器
        /// - Parameters:
        ///   - vc: 自控制器
        ///   - title: 在tabbar上的标题
        ///   - normalIcon: 正常状态图片
        ///   - selectIcon: 选中状态图片
        private func addChildren(_ childController:UIViewController,title:String,normalIcon:String,selectIcon:String,index:Int)  {
            let nvc = MCNavVC(rootViewController: childController)
            nvc.tabBarItem.image = UIImage(named: normalIcon)
            nvc.navigationBar.isTranslucent = false
            nvc.tabBarItem.selectedImage = UIImage(named: selectIcon)
            nvc.tabBarItem.title = title
            addChild(nvc)
        }
}
